<template>
<div id='login'>
  <div class="box">
    <div class="head">
      <span>劳模系统登录入口</span>
    </div>
    <div class="middle">
          <div class='middle_form'>
              <span>账号：<input  id='inputEmail3' v-model='account'></span>
              <br>
              <span style='margin-top:10px;'>密码：<input type='password'  id='inputPassword3' v-model='password'></span>
              <br>
          </div>
          <div class="middle_button" @click='login'>登录</div>
    </div>
  </div>
</div>
</template>
<style media="screen">
#login{
          position: fixed;
          width: 100%;
          height: 100%;
          background-image: url('../assets/background.jpg');
          background-size:cover;
}
.box{
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-top: 50px;
}
  .head{
      width: 350px;
      height: 40px;
      border-radius: 10px 10px 0 0;
      line-height: 40px;
      background-color: #58B7FF;
      color:white;
      font-weight: bold;
      text-shadow: 1px 1px 1px black;
  }
  .middle{
    display: flex;
    flex-direction: column;
    justify-content:center;
    align-items: center;
    border-radius:0 0 10px 10px;
    height: 280px;
    width: 350px;
    background-color: white;
  }
  .middle_form{
    height:40%;
    display:flex;
    flex-direction: column;
    justify-content:center;
    align-items: center;
  }
  .middle_button{
    width: 80px;
    height: 30px;
    line-height:30px;
    margin: 50px 0 10px 0;
    border: 1px solid #58B7FF;
    color:#58B7FF;
    border-radius:10px;
  }
  .button:hover{
    background-color:#58B7FF;
    color:white;
    font-weight: bold;
    cursor:pointer;
    border:1px solid #58B7FF;
  }
</style>
<script>
import myMenu from '@/components/Menu'
    export default{
        data(){
            return {
                account:'',
                password:'',
            }
        },
        mounted:function(){
          this.$http.get('/api/check_login').then(
            function(res){
              if(res.body.code==1){
                //alert(res.body.message)
                //this.$router.push('/home')
              }else{
              //alert(res.body.message);
              //this.$router.push('/login')
              }
            },function(err){
              alert('服务器连接错误')
            }
          )
        },
        methods:{
            login(){
                console.log(this.account)
                this.$http.post('/api/login/getAccount',{},{params:{account:this.account,password:this.password}}).then(
                    function(res){
                      if(res.body.code==1){
                        this.$router.push('/home')
                      }else{
                        alert(res.body.message);
                      }
                    },function(err){
                        console.log(err);
                    })
            }
        }
    }
</script>
